/* 移动端答题页面样式 */

.page-wrapper {
    padding-bottom: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: auto; /* 不创建新的堆叠上下文 */
}

/* 计时器 */
.timer-display {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-color);
    background: rgba(102, 126, 234, 0.1);
    padding: 6px 12px;
    border-radius: 8px;
}

/* 分类选择区 */
.category-selector {
    padding: 24px 0;
    max-height: calc(100vh - 80px); /* 减去底部导航高度 */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    z-index: 1; /* 设置较低的z-index */
}

.selector-title {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 20px;
    color: white;
}

.category-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
}

.category-btn {
    padding: 12px 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    flex: 0 0 auto;
}

.category-btn:active {
    transform: scale(0.98);
}

.category-btn.active {
    background: white;
    color: var(--primary-color);
    border-color: white;
}

/* 答题区 */
.quiz-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* 允许flex子项缩小 */
}

.quiz-area .container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding-bottom: 200px; /* 为底部导航和固定按钮留出更多空间 */
    position: relative;
    z-index: auto; /* 不设置z-index堆叠上下文 */
}

/* 进度部分 */
.progress-section {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
}

.question-number {
    font-weight: 600;
    color: var(--text-primary);
}

.score-display {
    font-weight: 600;
    color: var(--primary-color);
}

.progress-bar {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

/* 题目卡片 */
.question-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    position: relative;
    z-index: 1; /* 设置较低的z-index，确保不遮挡按钮 */
}

.question-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 20px;
}

/* 题目图片 */
.question-image-container {
    margin: 16px 0;
    text-align: center;
}

.question-image {
    max-width: 100%;
    max-height: 300px;
    width: auto;
    height: auto;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    object-fit: contain;
}

/* 选项列表 */
.options-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-item {
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: white;
}

.option-item:active {
    transform: scale(0.98);
}

.option-label {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.option-text {
    flex: 1;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-primary);
    word-break: break-word;
}

/* 选项图片 */
.option-image {
    max-width: 100%;
    max-height: 150px;
    width: auto;
    height: auto;
    border-radius: 8px;
    margin-top: 8px;
    object-fit: contain;
}

/* 填空题样式 */
.fill-in-container {
    padding: 24px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: white;
    margin-top: 16px;
}

.fill-in-label {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.fill-in-input {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    background: #f8f9fa;
    transition: all 0.3s;
    box-sizing: border-box;
}

.fill-in-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.fill-in-input::placeholder {
    color: #999;
}

.option-item.selected {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
}

.option-item.selected .option-label {
    background: var(--primary-color);
    color: white;
}

.option-item.correct {
    border-color: var(--success-color);
    background: rgba(72, 187, 120, 0.05);
}

.option-item.correct .option-label {
    background: var(--success-color);
    color: white;
}

.option-item.wrong {
    border-color: var(--danger-color);
    background: rgba(245, 101, 101, 0.05);
}

.option-item.wrong .option-label {
    background: var(--danger-color);
    color: white;
}

/* 操作按钮 - 已移至固定位置 */
.action-buttons {
    display: none; /* 隐藏原来的按钮位置 */
}

.action-buttons .btn-block {
    grid-column: 1 / -1;
}

/* 固定按钮容器 */
.quiz-navigation-fixed {
    position: fixed;
    bottom: 90px; /* 增加更多距离，完全避开导航栏 */
    left: 16px;
    right: 16px;
    z-index: 900; /* 低于导航栏，避免遮挡 */
    background: white;
    padding: 12px;
    border-radius: 16px;
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.1);
    display: none; /* 默认隐藏，开始答题后才显示 */
    gap: 12px;
}

.quiz-navigation-fixed.active {
    display: flex; /* 答题时显示 */
}

.quiz-navigation-fixed .btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quiz-navigation-fixed .btn-secondary {
    background: #6c757d;
    color: white;
}

.quiz-navigation-fixed .btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.quiz-navigation-fixed .btn-success {
    background: #28a745;
    color: white;
}

.quiz-navigation-fixed .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.quiz-navigation-fixed .btn:not(:disabled):active {
    transform: scale(0.95);
}

/* 结果区 */
.result-area {
    padding: 40px 0;
}

.result-card {
    background: white;
    border-radius: 20px;
    padding: 40px 24px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.result-icon {
    font-size: 80px;
    margin-bottom: 20px;
}

.result-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 30px;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.result-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.result-stat .stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.result-stat .stat-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.result-time {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.result-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 禁用状态 */
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 响应式调整 */
@media (max-width: 375px) {
    .question-title {
        font-size: 15px;
    }
    
    .option-text {
        font-size: 14px;
    }
    
    .result-icon {
        font-size: 64px;
    }
    
    .result-title {
        font-size: 20px;
    }
    
    .result-stat .stat-value {
        font-size: 28px;
    }
}

/* Markdown和KaTeX样式调整 */
.question-title .katex,
.option-text .katex {
    font-size: 1em;
}

.question-title .katex-display,
.option-text .katex-display {
    margin: 0.5em 0;
    overflow-x: auto;
}

/* ========== AI助手样式 ========== */
/* AI助手浮动按钮 */
.ai-assistant-btn {
    position: fixed !important;
    right: 20px !important;
    bottom: 160px !important; /* 调整位置，在答题按钮和导航栏之间 */
    width: 56px !important;
    height: 56px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
    font-size: 26px !important;
    cursor: pointer !important; /* 点击光标 */
    box-shadow: 0 6px 30px rgba(102, 126, 234, 0.6) !important;
    transition: all 0.3s ease;
    z-index: 9999 !important; /* 超高层级，确保不被任何元素遮挡 */
    display: flex !important; /* 强制显示 */
    align-items: center !important;
    justify-content: center !important;
    user-select: none; /* 防止拖动时选中文本 */
    touch-action: none; /* 防止移动端滚动冲突 */
    opacity: 1 !important; /* 确保不透明 */
    visibility: visible !important; /* 确保可见 */
    pointer-events: auto !important; /* 确保可点击 */
}

.ai-assistant-btn.dragging {
    transition: none; /* 拖动时禁用过渡效果 */
    opacity: 0.8;
}

.ai-assistant-btn:active {
    transform: scale(0.9);
}

/* 拖动时的光标 */
.ai-assistant-btn.dragging {
    cursor: move; /* 拖动时才显示移动光标 */
    opacity: 0.8; /* 拖动时半透明 */
}

/* AI对话框面板 */
.ai-chat-panel {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: white;
    display: none;
    flex-direction: column;
    z-index: 1001; /* 高于底部导航 */
}

.ai-chat-panel.active {
    display: flex;
    animation: slideInUp 0.3s ease;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* AI对话框头部 */
.ai-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    gap: 10px;
}

.ai-chat-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    flex: 1;
}

/* AI服务选择器 */
.ai-service-selector {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
    outline: none;
}

.ai-service-selector:active {
    background: rgba(255, 255, 255, 0.3);
}

.ai-service-selector option {
    background: #667eea;
    color: white;
}

.ai-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-close-btn:active {
    background: rgba(255, 255, 255, 0.4);
}

/* 消息区域 */
.ai-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f8f9fa;
    -webkit-overflow-scrolling: touch;
}

/* 消息样式 */
.ai-message {
    margin-bottom: 16px;
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-message-user {
    justify-content: flex-end;
}

.ai-message-assistant {
    justify-content: flex-start;
}

.ai-message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.ai-message-user .ai-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message-assistant .ai-message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 输入区域 */
.ai-chat-input-area {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.ai-chat-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    transition: border-color 0.2s;
}

.ai-chat-input:focus {
    outline: none;
    border-color: #667eea;
}

.ai-send-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    min-width: 60px;
}

.ai-send-btn:active {
    transform: scale(0.95);
}

.ai-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 加载动画 */
.ai-loading {
    display: inline-block;
}

.ai-loading::after {
    content: '...';
    animation: aiLoading 1.5s infinite;
}

@keyframes aiLoading {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

